<?php

require_once 'SDOUserStatSocket.php';

/*
 * SDOApiUserStatService
 * 封装SDO User Stat socket接口
 * @author Wolfhead (Mei xueting)
 */
class SDOApiUserStatService {
    

    /*
     * 心跳
     * @param string $uid 盛大用户id
     * @param int  $spid供应商id
     * @param int  $appid应用id
     * @param int  $area区编号
     * @param int  $group组编号
     * @return $array    
     */
    static public function HeartBeat($uid, $spid, $appid, $area, $group)
    {
        $apiName = "userstatservice.heartbeat";
        
        $param = array();
        
        
        $param['SndaId'] = $uid;
        $param['Position'] = sprintf("%d:%d:%d:%d", $spid, $appid, $area, $group);
        
        
        $result = self::send($apiName, $param);

        
        return $result;
    }
    
     /*
     * 查询用户状态
     * @param array|string $uids 盛大用户id数组
     * @return $array    
     */
    static public function QueryUserStatus($uids)
    {
        $apiName = "userstatservice.queryuserstatus";
        
        $param = array();
         
        $param['SndaId'] = $uids;
        
        $result = self::send($apiName, $param);

        return $result;
    }
    
    /*
     * 查询用户登陆状态
     * @param array|string $uids 盛大用户id数组
     * @return $array    
     */
    static public function QueryLoginInfo($uids)
    {
        $apiName = "userstatservice.querylogininfo";
        
        $param = array();
         
        $param['SndaId'] = $uids;
        
        $result = self::send($apiName, $param);

        return $result;
    }
    
    /*
     * 发送消息
     * @param array|string $NotifyMessages 消息数组
     * @return $array    
     */
    static public function DispatchNotice($NotifyMessages)
    {
        $apiName = "userstatservice.DispatchNotice";
        
        $param = array();
         
        $param['NotifyMsg'] = $NotifyMessages;
        
        $result = self::send($apiName, $param);

        return $result;
    }
    
     /*
     * 发送用户消息
     * @param array|string $uids 盛大用户id数组
     * @param array|string $NotifyMessages 消息数组
     * @return $array    
     */
    static public function SendUserNotice($uids, $NotifyMessages)
    {
        $apiName = "userstatservice.SendUserNotice";
        
        $param = array();
         
        $param['SndaId'] = $uids;
        $param['NotifyUserMsg'] = $NotifyMessages;
        
        $result = self::send($apiName, $param);

        return $result;
    }
    
    static protected function send($apiName, $param)
    {
        return SDOUserStatSocket::send($apiName, $param);
    }
}